<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>登录</title>

    <meta name="description" content="Source code generated using layoutit.com">
    <meta name="author" content="LayoutIt!">

    <link href="../static/css/bootstrap.min.css" rel="stylesheet">
    <link href="../static/css/style.css" rel="stylesheet">

  </head>

<body style="padding: 20px;background: url('../static/images/loginbg.jpg')">
<div class="container-fluid">
	<div class="row">
		<div class="col-md-6">
		</div>
		<div class="col-md-4">
			<form role="form"  method="post" id="login_data">
				<div class="form-group">

					<label for="exampleInputEmail1">
						Username
					</label>
					<input type="text" class="form-control" id="exampleInputEmail1" name="username" required/>
				</div>
				<div class="form-group">

					<label for="exampleInputPassword1">
						Password
					</label>
					<input type="password" class="form-control" id="exampleInputPassword1" name="pwd" required/>
				</div>

				<input type="button" class="btn btn-primary" value="登录" name="submit" id="sub"/>


                <a href="/signin" class="btn btn-primary">
					注册
				</a>
                <a href="/" class="btn btn-primary">
					返回首页
				</a>
			</form>
		</div>
		<div class="col-md-2">

		</div>
	</div>
</div>
<script src="../static/js/jquery.min.js" type="text/javascript"></script>
    <script  type="text/javascript" >

$("#sub").click(function(e) {
    $.ajax({
        url:'/login/run',
        type:'post',
        data:$("#login_data").serialize(),
        success:function (status) {
            console.log(status)
            if(status.status==200){
                alert('登录成功')
                window.location.href="/"
            }
            else if(status.status==1){
                alert('密码错误')
            }
            else if(status.status==2) {
                alert('用户不已存在')
            }
        }
    })
})
    </script>
</body>
</html>
